#pragma once
#include <vector>
#include "MatrixV.h"
#include "function.h"
using namespace std;
class Lax_Wendroff_method
{
private:
    double a,h,T,k,mu;
    int m;
    vector<vector<double>> A, B, C, I;
public:
    Lax_Wendroff_method(double _h, double _T, double _k):h(_h), T(_T), k(_k)
    {
	a = 1;
	m = 1/h - 1;
	mu = a*k*k/h;
	MatrixV M(a, h);
	A = M.A0();
	I = M.I0();
	B = M.B0();
	C = M.C0();
    };
    /// 根据初始条件函数创建 U^0
    vector<double> U0()
	{
	    vector<double> U0;
	    for (int i = 0; i < 9*(m+1)+m; i++)
	    {
		U0.push_back(u1((i+1-2)*h));
	    }
	    return U0;
	};
    /// 求解器,输入时间步数,保存求解结果到 U
    vector<double> Solver()
	{
	    vector<vector<double>> U;
	    U.push_back(U0());
	    int t = T/k;
	    for (int i = 0; i < t; i++)
	    {
		U.push_back(U[i] - 0.5*mu*B*U[i]+0.5*mu*mu/k*C*U[i]);
	    }
	    return U[t];
	};
};
